<?php
defined( '_PSPEXEC_' ) or die( 'Restricted access' );
class Param {
	public static $_params = array(
		'debug' => 0,	
	);	
	public static function write($config, $value = null) {
		if (!is_array($config)) {
			$config = array($config => $value);
		}
		foreach ($config as $name => $value) {
			$pointer = &self::$_params;
			foreach (explode('.', $name) as $key) {
				$pointer = &$pointer[$key];
			}
			$pointer = $value;
			unset($pointer);
		}
		if (isset($config['debug']) && function_exists('ini_set')) {
			if (self::$_params['debug']) {
				ini_set('display_errors', 1);
			} else {
				ini_set('display_errors', 0);
			}
		}
		return true;
	}	
	
	public static function read($var = null) {
		if ($var === null) {
			return self::$_params['debug'];
		}
		if (isset(self::$_params[$var])) {
			return self::$_params[$var];
		}
		$pointer = &self::$_params;
		foreach (explode('.', $var) as $key) {
			if (isset($pointer[$key])) {
				$pointer = &$pointer[$key];
			} else {
				return null;
			}
		}
		return $pointer;
	}	
		
	public static function delete($var = null) {
		$keys = explode('.', $var);
		$last = array_pop($keys);
		$pointer = &self::$_params;
		foreach ($keys as $key) {
			$pointer = &$pointer[$key];
		}
		unset($pointer[$last]);
	}
	
	public static function version() {
		return '1.0.0';
	}
	
				
}


?>